home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / PhonePanel.c < prev    next >
C/C++ Source or Header  |  1995-07-01  |  53KB  |  2,331 lines

  1. /*
  2. **    PhonePanel.c
  3. **
  4. **    The phonebook and support routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Gadget IDs. */
  13.  
  14. enum    {    GAD_NAMELIST,        GAD_EDIT,
  15.         GAD_NAME,        GAD_COMMENT,        GAD_PHONENUMBER,    GAD_QUICKMENU,
  16.         GAD_NEWENTRY,        GAD_DIALLIST,        GAD_LOADLIST,        GAD_COPYCONFIG,
  17.         GAD_CLONEENTRY,        GAD_CLEARLIST,        GAD_SORTLIST,        GAD_PASSWORD,
  18.         GAD_REMOVEENTRY,    GAD_USEIT,        GAD_SAVELIST,        GAD_PRINT,
  19.         GAD_TAG,        GAD_UNTAG,        GAD_TAG_ALL,        GAD_TOGGLE_ALL,
  20.         GAD_CANCEL
  21.     };
  22.  
  23.     /* Editing IDs. */
  24.  
  25. enum    {    EDIT_SERIAL,        EDIT_MODEM,        EDIT_SCREEN,        EDIT_TERMINAL,
  26.         EDIT_EMULATION,        EDIT_CLIPBOARD,        EDIT_CAPTURE,        EDIT_COMMANDS,
  27.         EDIT_MISC,        EDIT_PATHS,        EDIT_TRANSFER,        EDIT_TRANSLATION,
  28.         EDIT_KEYMACROS,        EDIT_CURSORKEYS,
  29.         EDIT_FASTMACROS,    EDIT_PASSWORD,        EDIT_RATES };
  30.  
  31.     /* What action is to follow clicking into the listview. */
  32.  
  33. enum    {    CLICK_NONE,CLICK_SELECT,CLICK_TOGGLE,CLICK_DIAL };
  34.  
  35.     /* Some hints. */
  36.  
  37. STATIC LONG LastSelected,LastNumPhoneEntries;
  38.  
  39.     /* ListViewRender():
  40.      *
  41.      *    This callback routine is responsible for rendering
  42.      *    the single listview entries.
  43.      */
  44.  
  45. STATIC ULONG __saveds __asm
  46. ListViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct PhoneNode *Node)
  47. {
  48.         /* We only know how to redraw lines. */
  49.  
  50.     if(Msg -> lvdm_MethodID == LV_DRAW)
  51.     {
  52.         struct RastPort    *RPort    = Msg -> lvdm_RastPort;
  53.         LONG         Count    = Node -> Entry -> Count + 1,
  54.                  Left    = Msg -> lvdm_Bounds . MinX,
  55.                  Top    = Msg -> lvdm_Bounds . MinY,
  56.                  Width    = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
  57.                  Height    = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
  58.                  FgPen,BgPen,
  59.                  Template,
  60.                  Len,LabelLen;
  61.         UBYTE         String[80],Num[8];
  62.  
  63.             /* Determine the rendering pens. */
  64.  
  65.         switch(Msg -> lvdm_State)
  66.         {
  67.             case LVR_SELECTEDDISABLED:
  68.             case LVR_NORMALDISABLED:
  69.             case LVR_NORMAL:
  70.  
  71.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
  72.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
  73.                 break;
  74.  
  75.             case LVR_SELECTED:
  76.  
  77.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
  78.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
  79.                 break;
  80.         }
  81.  
  82.         if(Count > 0)
  83.         {
  84.             if(Msg -> lvdm_DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN] != BgPen)
  85.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN];
  86.         }
  87.  
  88.         SetAPen(RPort,BgPen);
  89.         RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
  90.  
  91.         Left    += 2;
  92.         Width    -= 2;
  93.  
  94.             /* Determine maximum index text length. */
  95.  
  96.         Template = 3 * ((ULONG)Hook -> h_Data) + TextLength(RPort," - ",3);
  97.  
  98.             /* Get the vanilla name. */
  99.  
  100.         strcpy(String,&Node -> VanillaNode . ln_Name[6]);
  101.  
  102.             /* Set the rendering pens. */
  103.  
  104.         SetDrMd(RPort,JAM2);
  105.         SetBPen(RPort,BgPen);
  106.  
  107.             /* Has this entry been selected? */
  108.  
  109.         if(Count > 0)
  110.         {
  111.             LONG Delta;
  112.  
  113.                 /* Set up the header. */
  114.  
  115.             SPrintf(Num,"%3ld - ",Count);
  116.  
  117.                 /* Determine header length. */
  118.  
  119.             Len = TextLength(RPort,Num,6);
  120.  
  121.                 /* Fill the space to precede the header. */
  122.  
  123.             if((Delta = Template - Len) > 0)
  124.             {
  125.                 SetAPen(RPort,BgPen);
  126.                 RectFill(RPort,Left,Top,Left + Delta - 1,Top + Height - 1);
  127.             }
  128.  
  129.                 /* Render the header, right-justified. */
  130.  
  131.             SetAPen(RPort,FgPen);
  132.  
  133.             Move(RPort,Left + Delta,Top + RPort -> Font -> tf_Baseline);
  134.             Text(RPort,Num,6);
  135.         }
  136.         else
  137.         {
  138.                 /* Fill the blank space to precede the vanilla name. */
  139.  
  140.             SetAPen(RPort,BgPen);
  141.             RectFill(RPort,Left,Top,Left + Template - 1,Top + Height - 1);
  142.             SetAPen(RPort,FgPen);
  143.         }
  144.  
  145.             /* Adjust width and area left edge. */
  146.  
  147.         Left    += Template;
  148.         Width    -= Template;
  149.  
  150.             /* Determine length of vanilla name. */
  151.  
  152.         LabelLen = strlen(String);
  153.  
  154.             /* Try to make it fit. */
  155.  
  156.         while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
  157.             LabelLen--;
  158.  
  159.             /* Print the vanilla name if possible. */
  160.  
  161.         if(LabelLen)
  162.         {
  163.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  164.             Text(RPort,String,LabelLen);
  165.  
  166.             Left    += Len;
  167.             Width    -= Len;
  168.         }
  169.  
  170.             /* Fill the area to follow the vanilla name. */
  171.  
  172.         if(Width > 0)
  173.         {
  174.             SetAPen(RPort,BgPen);
  175.             RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
  176.         }
  177.  
  178.             /* If the item happens to be disabled, draw the cross-hatch
  179.              * pattern across it.
  180.              */
  181.  
  182.         if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
  183.         {
  184.             SetDrMd(RPort,JAM1);
  185.  
  186.             SetAPen(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN]);
  187.  
  188.             SetAfPt(RPort,(UWORD *)&Ghosting,1);
  189.  
  190.             RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
  191.  
  192.             SetAfPt(RPort,NULL,0);
  193.         }
  194.  
  195.         return(LVCB_OK);
  196.     }
  197.     else
  198.         return(LVCB_UNKNOWN);
  199. }
  200.  
  201. STATIC ULONG __saveds __asm
  202. EditViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct Node *Node)
  203. {
  204.         /* We only know how to redraw lines. */
  205.  
  206.     if(Msg -> lvdm_MethodID == LV_DRAW)
  207.     {
  208.         struct RastPort    *RPort    = Msg -> lvdm_RastPort;
  209.         LONG         Left    = Msg -> lvdm_Bounds . MinX,
  210.                  Top    = Msg -> lvdm_Bounds . MinY,
  211.                  Width    = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
  212.                  Height    = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
  213.                  FgPen,BgPen,
  214.                  Template,
  215.                  Len,LabelLen;
  216.         STRPTR         String = Node -> ln_Name;
  217.  
  218.             /* Determine the rendering pens. */
  219.  
  220.         switch(Msg -> lvdm_State)
  221.         {
  222.             case LVR_SELECTEDDISABLED:
  223.             case LVR_NORMALDISABLED:
  224.             case LVR_NORMAL:
  225.  
  226.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
  227.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
  228.                 break;
  229.  
  230.             case LVR_SELECTED:
  231.  
  232.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
  233.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
  234.                 break;
  235.         }
  236.  
  237.         SetAPen(RPort,BgPen);
  238.         RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
  239.  
  240.         Left    += 2;
  241.         Width    -= 2;
  242.  
  243.             /* Determine maximum index text length. */
  244.  
  245.         Template = TextLength(RPort,"*",1);
  246.  
  247.             /* Set the rendering pens. */
  248.  
  249.         SetDrMd(RPort,JAM2);
  250.         SetBPen(RPort,BgPen);
  251.  
  252.             /* Has this entry been selected? */
  253.  
  254.         if(*String == '*')
  255.         {
  256.                 /* Render the header, right-justified. */
  257.  
  258.             SetAPen(RPort,FgPen);
  259.  
  260.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  261.             Text(RPort,"*",1);
  262.         }
  263.         else
  264.         {
  265.                 /* Fill the blank space to precede the vanilla name. */
  266.  
  267.             SetAPen(RPort,BgPen);
  268.             RectFill(RPort,Left,Top,Left + Template - 1,Top + Height - 1);
  269.             SetAPen(RPort,FgPen);
  270.         }
  271.  
  272.             /* Adjust width and area left edge. */
  273.  
  274.         Left    += Template;
  275.         Width    -= Template;
  276.  
  277.         String++;
  278.  
  279.             /* Determine length of vanilla name. */
  280.  
  281.         LabelLen = strlen(String);
  282.  
  283.             /* Try to make it fit. */
  284.  
  285.         while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
  286.             LabelLen--;
  287.  
  288.             /* Print the vanilla name if possible. */
  289.  
  290.         if(LabelLen)
  291.         {
  292.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  293.             Text(RPort,String,LabelLen);
  294.  
  295.             Left    += Len;
  296.             Width    -= Len;
  297.         }
  298.  
  299.             /* Fill the area to follow the vanilla name. */
  300.  
  301.         if(Width > 0)
  302.         {
  303.             SetAPen(RPort,BgPen);
  304.             RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
  305.         }
  306.  
  307.             /* If the item happens to be disabled, draw the cross-hatch
  308.              * pattern across it.
  309.              */
  310.  
  311.         if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
  312.         {
  313.             SetDrMd(RPort,JAM1);
  314.  
  315.             SetAPen(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN]);
  316.  
  317.             SetAfPt(RPort,(UWORD *)&Ghosting,1);
  318.  
  319.             RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
  320.  
  321.             SetAfPt(RPort,NULL,0);
  322.         }
  323.  
  324.         return(LVCB_OK);
  325.     }
  326.     else
  327.         return(LVCB_UNKNOWN);
  328. }
  329.  
  330. STATIC VOID __regargs
  331. UpdateEditList(struct Configuration *Config)
  332. {
  333.     ULONG    *Array;
  334.     WORD     i;
  335.  
  336.     Array = (ULONG *)Config;
  337.  
  338.     for(i = 0 ; i < 10 ; i++)
  339.     {
  340.         if(Array[i])
  341.             EditLabels[i][0] = (UBYTE)'*';
  342.         else
  343.             EditLabels[i][0] = ' ';
  344.     }
  345.  
  346.     if(Config -> TransferConfig)
  347.         EditLabels[10][0] = (UBYTE)'*';
  348.     else
  349.         EditLabels[10][0] = ' ';
  350.  
  351.     EditLabels[15][0] = (UBYTE)'*';
  352.     EditLabels[16][0] = (UBYTE)'*';
  353.  
  354.     if(Config -> FileConfig)
  355.     {
  356.         EditLabels[11][0] = (UBYTE)'*';
  357.         EditLabels[12][0] = (UBYTE)'*';
  358.         EditLabels[13][0] = (UBYTE)'*';
  359.         EditLabels[14][0] = (UBYTE)'*';
  360.     }
  361.     else
  362.     {
  363.         EditLabels[11][0] = ' ';
  364.         EditLabels[12][0] = ' ';
  365.         EditLabels[13][0] = ' ';
  366.         EditLabels[14][0] = ' ';
  367.     }
  368. }
  369.  
  370. STATIC BOOLEAN
  371. SaveChanges(struct Window *Parent)
  372. {
  373.     return((BOOLEAN)MyEasyRequest(Parent,LocaleString(MSG_SAVE_CHANGES),LocaleString(MSG_GLOBAL_YES_NO_TXT)));
  374. }
  375.  
  376. STATIC BYTE __regargs
  377. EditConfig(struct Configuration *Config,UWORD Type,ULONG Qualifier,struct Window *Window)
  378. {
  379.     STATIC LONG TypeMappings[15][2] =
  380.     {
  381.         EDIT_SERIAL,        PREF_SERIAL,
  382.         EDIT_MODEM,        PREF_MODEM,
  383.         EDIT_SCREEN,        PREF_SCREEN,
  384.         EDIT_TERMINAL,        PREF_TERMINAL,
  385.         EDIT_EMULATION,        PREF_EMULATION,
  386.         EDIT_CLIPBOARD,        PREF_CLIP,
  387.         EDIT_CAPTURE,        PREF_CAPTURE,
  388.         EDIT_COMMANDS,        PREF_COMMAND,
  389.         EDIT_MISC,        PREF_MISC,
  390.         EDIT_PATHS,        PREF_PATH,
  391.         EDIT_TRANSFER,        PREF_TRANSFER,
  392.         EDIT_TRANSLATION,    PREF_FILE,
  393.         EDIT_KEYMACROS,        PREF_FILE,
  394.         EDIT_CURSORKEYS,    PREF_FILE,
  395.         EDIT_FASTMACROS,    PREF_FILE
  396.     };
  397.  
  398.     struct FileRequester    *FileRequest;
  399.     UBYTE             DummyBuffer[MAX_FILENAME_LENGTH],
  400.                 *DummyChar;
  401.     BOOLEAN             Changed    = FALSE,
  402.                  Default    = FALSE,
  403.                  FallBack    = TRUE;
  404.     LONG             PrefType;
  405.     WORD             i;
  406.     APTR             Data;
  407.  
  408.     for(i = 0 ; i < 15 ; i++)
  409.     {
  410.         if(TypeMappings[i][0] == Type)
  411.         {
  412.             PrefType = TypeMappings[i][1];
  413.  
  414.             break;
  415.         }
  416.     }
  417.  
  418.     Data = GetConfigEntry(Config,PrefType);
  419.  
  420.     if(CreateConfigEntry(Config,PrefType))
  421.     {
  422.         if(!Data)
  423.             ResetConfigEntry(Config,PrefType,FALSE);
  424.  
  425.         switch(Type)
  426.         {
  427.             case EDIT_SERIAL:
  428.  
  429.                 Changed = SerialPanel(Config,&Default);
  430.                 break;
  431.  
  432.             case EDIT_MODEM:
  433.  
  434.                 Changed = ModemPanel(Config,&Default);
  435.                 break;
  436.  
  437.             case EDIT_SCREEN:
  438.  
  439.                 Changed = ScreenPanel(Config,&Default);
  440.                 break;
  441.  
  442.             case EDIT_TERMINAL:
  443.  
  444.                 Changed = TerminalPanel(Config,&Default);
  445.                 break;
  446.  
  447.             case EDIT_EMULATION:
  448.  
  449.                 Changed = EmulationPanel(Config,&Default);
  450.                 break;
  451.  
  452.             case EDIT_CLIPBOARD:
  453.  
  454.                 Changed = ClipPanel(Config,&Default);
  455.                 break;
  456.  
  457.             case EDIT_CAPTURE:
  458.  
  459.                 Changed = CapturePanel(Config,&Default);
  460.                 break;
  461.  
  462.             case EDIT_COMMANDS:
  463.  
  464.                 Changed = CommandPanel(Config,&Default);
  465.                 break;
  466.  
  467.             case EDIT_MISC:
  468.  
  469.                 Changed = MiscPanel(Config,&Default);
  470.                 break;
  471.  
  472.             case EDIT_PATHS:
  473.  
  474.                 Changed = PathPanel(Config,&Default);
  475.                 break;
  476.  
  477.             case EDIT_TRANSFER:
  478.  
  479.                 Changed = LibPanel(Config,&Default);
  480.                 break;
  481.  
  482.             case EDIT_TRANSLATION:
  483.  
  484.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  485.                 {
  486.                     struct TranslationEntry **Send,**Receive = NULL;
  487.                     BOOLEAN            Success = FALSE;
  488.  
  489.                     strcpy(DummyBuffer,Config -> FileConfig -> TranslationFileName);
  490.  
  491.                     if(Send = AllocTranslationTable())
  492.                     {
  493.                         if(Receive = AllocTranslationTable())
  494.                         {
  495.                             Success = TRUE;
  496.  
  497.                             if(DummyBuffer[0])
  498.                             {
  499.                                 if(!LoadTranslationTables(DummyBuffer,Send,Receive))
  500.                                 {
  501.                                     ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  502.  
  503.                                     FillTranslationTable(Send);
  504.                                     FillTranslationTable(Receive);
  505.                                 }
  506.                             }
  507.                             else
  508.                             {
  509.                                 FillTranslationTable(Send);
  510.                                 FillTranslationTable(Receive);
  511.                             }
  512.                         }
  513.                     }
  514.  
  515.                     if(Success)
  516.                     {
  517.                         if(TranslationPanel(&Send,&Receive,DummyBuffer,Window))
  518.                         {
  519.                             if(Send || Receive)
  520.                             {
  521.                                 if(IsStandardTable(Send) && IsStandardTable(Receive))
  522.                                     DummyBuffer[0] = 0;
  523.  
  524.                                 if(DummyBuffer[0])
  525.                                 {
  526.                                     if(SaveChanges(Window))
  527.                                     {
  528.                                         if(!SaveTranslationTables(DummyBuffer,Send,Receive))
  529.                                             ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  530.                                     }
  531.                                 }
  532.                             }
  533.                             else
  534.                                 DummyBuffer[0] = 0;
  535.                         }
  536.  
  537.                         if(strcmp(Config -> FileConfig -> TranslationFileName,DummyBuffer))
  538.                         {
  539.                             strcpy(Config -> FileConfig -> TranslationFileName,DummyBuffer);
  540.  
  541.                             Changed = TRUE;
  542.                         }
  543.  
  544.                         FallBack = FALSE;
  545.                     }
  546.  
  547.                     if(Send)
  548.                         FreeTranslationTable(Send);
  549.  
  550.                     if(Receive)
  551.                         FreeTranslationTable(Receive);
  552.                 }
  553.  
  554.                 if(FallBack)
  555.                 {
  556.                     SplitFileName(Config -> FileConfig -> TranslationFileName,&DummyChar,DummyBuffer);
  557.  
  558.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_TRANSLATION_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  559.                     {
  560.                         strcpy(Config -> FileConfig -> TranslationFileName,DummyBuffer);
  561.  
  562.                         FreeAslRequest(FileRequest);
  563.  
  564.                         Changed = TRUE;
  565.                     }
  566.                 }
  567.  
  568.                 break;
  569.  
  570.             case EDIT_KEYMACROS:
  571.  
  572.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  573.                 {
  574.                     struct MacroKeys *Keys;
  575.  
  576.                     if(Keys = (struct MacroKeys *)AllocVecPooled(sizeof(struct MacroKeys),MEMF_ANY | MEMF_CLEAR))
  577.                     {
  578.                         strcpy(DummyBuffer,Config -> FileConfig -> MacroFileName);
  579.  
  580.                         if(DummyBuffer[0])
  581.                         {
  582.                             if(!LoadMacros(DummyBuffer,Keys))
  583.                                 ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  584.                         }
  585.  
  586.                         if(MacroPanel(Keys,DummyBuffer,FALSE,Window))
  587.                         {
  588.                             if(SaveChanges(Window))
  589.                             {
  590.                                 if(!WriteIFFData(DummyBuffer,Keys,sizeof(struct MacroKeys),ID_KEYS))
  591.                                     ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  592.                             }
  593.                         }
  594.  
  595.                         if(strcmp(Config -> FileConfig -> MacroFileName,DummyBuffer))
  596.                         {
  597.                             strcpy(Config -> FileConfig -> MacroFileName,DummyBuffer);
  598.  
  599.                             Changed = TRUE;
  600.                         }
  601.  
  602.                         FallBack = FALSE;
  603.  
  604.                         FreeVecPooled(Keys);
  605.                     }
  606.                 }
  607.  
  608.                 if(FallBack)
  609.                 {
  610.                     SplitFileName(Config -> FileConfig -> MacroFileName,&DummyChar,DummyBuffer);
  611.  
  612.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_KEYBOARD_MACROS_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  613.                     {
  614.                         strcpy(Config -> FileConfig -> MacroFileName,DummyBuffer);
  615.  
  616.                         FreeAslRequest(FileRequest);
  617.  
  618.                         Changed = TRUE;
  619.                     }
  620.                 }
  621.  
  622.                 break;
  623.  
  624.             case EDIT_CURSORKEYS:
  625.  
  626.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  627.                 {
  628.                     struct CursorKeys *Keys;
  629.  
  630.                     if(Keys = (struct CursorKeys *)AllocVecPooled(sizeof(struct CursorKeys),MEMF_ANY | MEMF_CLEAR))
  631.                     {
  632.                         strcpy(DummyBuffer,Config -> FileConfig -> CursorFileName);
  633.  
  634.                         if(DummyBuffer[0])
  635.                         {
  636.                             if(!ReadIFFData(DummyBuffer,Keys,sizeof(struct CursorKeys),ID_KEYS))
  637.                             {
  638.                                 ResetCursorKeys(Keys);
  639.  
  640.                                 ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  641.                             }
  642.                         }
  643.                         else
  644.                             ResetCursorKeys(Keys);
  645.  
  646.                         if(CursorPanel(Keys,DummyBuffer,Window))
  647.                         {
  648.                             if(SaveChanges(Window))
  649.                             {
  650.                                 if(!WriteIFFData(DummyBuffer,Keys,sizeof(struct CursorKeys),ID_KEYS))
  651.                                     ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  652.                             }
  653.                         }
  654.  
  655.                         if(strcmp(Config -> FileConfig -> CursorFileName,DummyBuffer))
  656.                         {
  657.                             strcpy(Config -> FileConfig -> CursorFileName,DummyBuffer);
  658.  
  659.                             Changed = TRUE;
  660.                         }
  661.  
  662.                         FallBack = FALSE;
  663.  
  664.                         FreeVecPooled(Keys);
  665.                     }
  666.                 }
  667.  
  668.                 if(FallBack)
  669.                 {
  670.                     SplitFileName(Config -> FileConfig -> CursorFileName,&DummyChar,DummyBuffer);
  671.  
  672.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_CURSOR_KEYS_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  673.                     {
  674.                         strcpy(Config -> FileConfig -> CursorFileName,DummyBuffer);
  675.  
  676.                         FreeAslRequest(FileRequest);
  677.  
  678.                         Changed = TRUE;
  679.                     }
  680.                 }
  681.  
  682.                 break;
  683.  
  684.             case EDIT_FASTMACROS:
  685.  
  686.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  687.                 {
  688.                     struct List *List;
  689.  
  690.                     if(List = CreateList())
  691.                     {
  692.                         strcpy(DummyBuffer,Config -> FileConfig -> FastMacroFileName);
  693.  
  694.                         if(DummyBuffer[0])
  695.                         {
  696.                             if(!LoadFastMacros(DummyBuffer,List))
  697.                                 ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  698.                         }
  699.  
  700.                         if(FastMacroPanel(List,DummyBuffer,Window,NULL))
  701.                         {
  702.                             if(SaveChanges(Window))
  703.                             {
  704.                                 if(!SaveFastMacros(DummyBuffer,List))
  705.                                     ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  706.                             }
  707.                         }
  708.  
  709.                         if(strcmp(Config -> FileConfig -> FastMacroFileName,DummyBuffer))
  710.                         {
  711.                             strcpy(Config -> FileConfig -> FastMacroFileName,DummyBuffer);
  712.  
  713.                             Changed = TRUE;
  714.                         }
  715.  
  716.                         FallBack = FALSE;
  717.  
  718.                         DeleteList(List);
  719.                     }
  720.                 }
  721.  
  722.                 if(FallBack)
  723.                 {
  724.                     SplitFileName(Config -> FileConfig -> FastMacroFileName,&DummyChar,DummyBuffer);
  725.  
  726.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_FAST_MACROS_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  727.                     {
  728.                         strcpy(Config -> FileConfig -> FastMacroFileName,DummyBuffer);
  729.  
  730.                         FreeAslRequest(FileRequest);
  731.  
  732.                         Changed = TRUE;
  733.                     }
  734.                 }
  735.  
  736.                 break;
  737.         }
  738.  
  739.         if((!Changed && !Data) || Default)
  740.         {
  741.             DeleteConfigEntry(Config,PrefType);
  742.  
  743.             if(Default)
  744.                 Changed = TRUE;
  745.         }
  746.     }
  747.     else
  748.         DisplayBeep(Window -> WScreen);
  749.  
  750.     return(Changed);
  751. }
  752.  
  753. STATIC VOID __regargs
  754. SetPanelState(struct LayoutHandle *Handle,struct List *PhoneList,LONG Count,LONG Selected)
  755. {
  756.     if(NumPhoneEntries)
  757.     {
  758.         LT_SetAttributes(Handle,GAD_SAVELIST,
  759.             GA_Disabled,    FALSE,
  760.         TAG_DONE);
  761.  
  762.         LT_SetAttributes(Handle,GAD_PRINT,
  763.             GA_Disabled,    FALSE,
  764.         TAG_DONE);
  765.  
  766.         LT_SetAttributes(Handle,GAD_SORTLIST,
  767.             GA_Disabled,    NumPhoneEntries < 2,
  768.         TAG_DONE);
  769.  
  770.         LT_SetAttributes(Handle,GAD_PASSWORD,
  771.             GA_Disabled,    FALSE,
  772.         TAG_DONE);
  773.  
  774.         LT_SetAttributes(Handle,GAD_CLONEENTRY,
  775.             GA_Disabled,    Selected == -1,
  776.         TAG_DONE);
  777.  
  778.         LT_SetAttributes(Handle,GAD_REMOVEENTRY,
  779.             GA_Disabled,    Selected == -1,
  780.         TAG_DONE);
  781.  
  782.         LT_SetAttributes(Handle,GAD_COPYCONFIG,
  783.             GA_Disabled,    FALSE,
  784.         TAG_DONE);
  785.  
  786.         LT_SetAttributes(Handle,GAD_USEIT,
  787.             GA_Disabled,    Selected == -1,
  788.         TAG_DONE);
  789.  
  790.         if(Selected == -1)
  791.         {
  792.             LT_SetAttributes(Handle,GAD_EDIT,
  793.                 GA_Disabled,    TRUE,
  794.             TAG_DONE);
  795.  
  796.             if(Selected != LastSelected)
  797.             {
  798.                 LT_SetAttributes(Handle,GAD_NAMELIST,
  799.                     GA_Disabled,    FALSE,
  800.                     GTLV_Selected,    ~0,
  801.                 TAG_DONE);
  802.  
  803.                 LT_SetAttributes(Handle,GAD_NAME,
  804.                     GTST_String,    "",
  805.                     GA_Disabled,    TRUE,
  806.                 TAG_DONE);
  807.  
  808.                 LT_SetAttributes(Handle,GAD_COMMENT,
  809.                     GTST_String,    "",
  810.                     GA_Disabled,    TRUE,
  811.                 TAG_DONE);
  812.  
  813.                 LT_SetAttributes(Handle,GAD_PHONENUMBER,
  814.                     GTST_String,    "",
  815.                     GA_Disabled,    TRUE,
  816.                 TAG_DONE);
  817.  
  818.                 LT_SetAttributes(Handle,GAD_QUICKMENU,
  819.                     GTCB_Checked,    FALSE,
  820.                     GA_Disabled,    TRUE,
  821.                 TAG_DONE);
  822.             }
  823.  
  824.             LT_SetAttributes(Handle,GAD_TAG,
  825.                 GA_Disabled,    TRUE,
  826.             TAG_DONE);
  827.  
  828.             LT_SetAttributes(Handle,GAD_UNTAG,
  829.                 GA_Disabled,    TRUE,
  830.             TAG_DONE);
  831.  
  832.             LT_SetAttributes(Handle,GAD_DIALLIST,
  833.                 GA_Disabled,    (Online && !Config -> MiscConfig -> ProtectiveMode) || !Count,
  834.             TAG_DONE);
  835.         }
  836.         else
  837.         {
  838.             LT_SetAttributes(Handle,GAD_NAMELIST,
  839.                 GA_Disabled,    FALSE,
  840.                 GTLV_Labels,    PhoneList,
  841.             TAG_DONE);
  842.  
  843.             if(Selected != LastSelected)
  844.             {
  845.                 LT_SetAttributes(Handle,GAD_NAME,
  846.                     GTST_String,    Phonebook[Selected] -> Header -> Name,
  847.                     GA_Disabled,    FALSE,
  848.                 TAG_DONE);
  849.  
  850.                 LT_SetAttributes(Handle,GAD_COMMENT,
  851.                     GTST_String,    Phonebook[Selected] -> Header -> Comment,
  852.                     GA_Disabled,    FALSE,
  853.                 TAG_DONE);
  854.  
  855.                 LT_SetAttributes(Handle,GAD_PHONENUMBER,
  856.                     GTST_String,    Phonebook[Selected] -> Header -> Number,
  857.                     GA_Disabled,    FALSE,
  858.                 TAG_DONE);
  859.  
  860.                 LT_SetAttributes(Handle,GAD_QUICKMENU,
  861.                     GTCB_Checked,    Phonebook[Selected] -> Header -> QuickMenu,
  862.                     GA_Disabled,    FALSE,
  863.                 TAG_DONE);
  864.  
  865.                 LT_SetAttributes(Handle,GAD_EDIT,
  866.                     GTLV_Labels,    ~0,
  867.                 TAG_DONE);
  868.  
  869.                 UpdateEditList(Phonebook[Selected] -> Config);
  870.  
  871.                 LT_SetAttributes(Handle,GAD_EDIT,
  872.                     GTLV_Labels,    EditList,
  873.                     GA_Disabled,    FALSE,
  874.                 TAG_DONE);
  875.             }
  876.             else
  877.             {
  878.                 LT_SetAttributes(Handle,GAD_EDIT,
  879.                     GA_Disabled,    FALSE,
  880.                 TAG_DONE);
  881.             }
  882.  
  883.             LT_SetAttributes(Handle,GAD_TAG,
  884.                 GA_Disabled,    Phonebook[Selected] -> Count != -1,
  885.             TAG_DONE);
  886.  
  887.             LT_SetAttributes(Handle,GAD_UNTAG,
  888.                 GA_Disabled,    Phonebook[Selected] -> Count == -1,
  889.             TAG_DONE);
  890.  
  891.             LT_SetAttributes(Handle,GAD_DIALLIST,
  892.                 GA_Disabled,    (Online && !Config -> MiscConfig -> ProtectiveMode) || !Phonebook[Selected] -> Header -> Number[0],
  893.             TAG_DONE);
  894.         }
  895.  
  896.         LT_SetAttributes(Handle,GAD_TAG_ALL,
  897.             GA_Disabled,    Count == NumPhoneEntries,
  898.         TAG_DONE);
  899.  
  900.         LT_SetAttributes(Handle,GAD_TOGGLE_ALL,
  901.             GA_Disabled,    FALSE,
  902.         TAG_DONE);
  903.  
  904.         LT_SetAttributes(Handle,GAD_CLEARLIST,
  905.             GA_Disabled,    !Count,
  906.         TAG_DONE);
  907.     }
  908.     else
  909.     {
  910.         LONG i;
  911.  
  912.         for(i = GAD_NAMELIST ; i < GAD_CANCEL ; i++)
  913.         {
  914.             LT_SetAttributes(Handle,i,
  915.                 GA_Disabled,    i != GAD_LOADLIST && i != GAD_NEWENTRY,
  916.             TAG_DONE);
  917.         }
  918.     }
  919.  
  920.     LastSelected = Selected;
  921. }
  922.  
  923. BYTE
  924. PhonePanel()
  925. {
  926.     struct LayoutHandle    *Handle;
  927.     struct PhoneNode    *TempNode;
  928.     struct List        *PhoneList;
  929.     LONG             Count;
  930.     BYTE             DialTheList = FALSE;
  931.  
  932.     LastSelected = LastNumPhoneEntries = -17;
  933.  
  934.     if(Phonebook && NumPhoneEntries)
  935.     {
  936.         LONG i;
  937.  
  938.         if(!(PhoneList = CreatePhoneList()))
  939.         {
  940.             DisplayBeep(Window -> WScreen);
  941.  
  942.             return(FALSE);
  943.         }
  944.  
  945.         FreeDialList(TRUE);
  946.  
  947.         for(i = 0, Count = -1 ; i < NumPhoneEntries ; i++)
  948.         {
  949.             if(Phonebook[i] -> Count > Count)
  950.                 Count = Phonebook[i] -> Count;
  951.         }
  952.  
  953.         Count++;
  954.     }
  955.     else
  956.     {
  957.         PhoneList    = NULL;
  958.         Count        = 0;
  959.     }
  960.  
  961.     if(Handle = LT_CreateHandleTags(Window -> WScreen,
  962.         LH_LocaleHook,        &LocaleHook,
  963. /*        LH_AutoActivate,    TRUE,*/
  964.     TAG_DONE))
  965.     {
  966.         STATIC struct Hook ListViewHook =
  967.         {
  968.             {NULL},
  969.             (HOOKFUNC)ListViewRender
  970.         };
  971.  
  972.         STATIC struct Hook EditViewHook =
  973.         {
  974.             {NULL},
  975.             (HOOKFUNC)EditViewRender
  976.         };
  977.  
  978.         STATIC LONG LabelIDTable[] =
  979.         {
  980.             MSG_PHONEPANEL_LOAD_LIST_GAD,
  981.             MSG_PHONEPANEL_SAVE_LIST_GAD,
  982.             MSG_PHONEPANEL_PRINT_GAD,
  983.             MSG_PHONEPANEL_SORT_LIST_GAD,
  984.             MSG_PHONEPANEL_SET_PASSWORT_GAD,
  985.             MSG_PHONEPANEL_NEW_ENTRY_GAD,
  986.             MSG_PHONEPANEL_CLONE_ENTRY_GAD,
  987.             MSG_PHONEPANEL_REMOVE_ENTRY_GAD,
  988.             MSG_PHONEPANEL_COPY_CONFIG_GAD,
  989.             MSG_PHONEPANEL_USE_ENTRY_GAD,
  990.             MSG_PHONEPANEL_TAG_GAD,
  991.             MSG_PHONEPANEL_UNTAG_GAD,
  992.             MSG_PHONEPANEL_TAG_ALL_GAD,
  993.             MSG_PHONEPANEL_TOGGLE_ALL_GAD,
  994.             MSG_PHONEPANEL_UNTAG_ALL_GAD
  995.         };
  996.  
  997.         struct IBox     Bounds;
  998.         struct Window    *PhoneWindow;
  999.         LONG         i,Max,Size,MaxPen,MaxChars;
  1000.         UBYTE         SmallString[2];
  1001.  
  1002.         for(i = MaxChars = 0 ; i < NumElements(LabelIDTable) ; i++)
  1003.         {
  1004.             if((Max = LT_LabelChars(Handle,LocaleString(LabelIDTable[i]))) > MaxChars)
  1005.                 MaxChars = Max;
  1006.         }
  1007.  
  1008.         MaxPen = MAX(Handle -> DrawInfo -> dri_Pens[BLOCKPEN],MAX(Handle -> DrawInfo -> dri_Pens[TEXTPEN],MAX(Handle -> DrawInfo -> dri_Pens[BACKGROUNDPEN],MAX(Handle -> DrawInfo -> dri_Pens[FILLTEXTPEN],MAX(Handle -> DrawInfo -> dri_Pens[FILLPEN],Handle -> DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN])))));
  1009.  
  1010.         SmallString[1] = 0;
  1011.         Max = 0;
  1012.  
  1013.         for(i = MSG_PHONEPANEL_SERIAL_TXT ; i <= MSG_PHONEPANEL_RATES_TXT ; i++)
  1014.             EditLabels[i - MSG_PHONEPANEL_SERIAL_TXT][0] = ' ';
  1015.  
  1016.         for(i = '0' ; i <= '9' ; i++)
  1017.         {
  1018.             SmallString[0] = i;
  1019.  
  1020.             if((Size = LT_LabelWidth(Handle,SmallString)) > Max)
  1021.                 Max = Size;
  1022.         }
  1023.  
  1024.         ListViewHook . h_Data = (APTR)Max;
  1025.  
  1026.         LT_New(Handle,
  1027.             LA_Type,    VERTICAL_KIND,
  1028.         TAG_DONE);
  1029.         {
  1030.             LT_New(Handle,
  1031.                 LA_Type,    VERTICAL_KIND,
  1032. /*                LA_LabelID,    MSG_V36_0132,*/
  1033.             TAG_DONE);
  1034.             {
  1035.                 LT_New(Handle,
  1036.                     LA_Type,    HORIZONTAL_KIND,
  1037.                 TAG_DONE);
  1038.                 {
  1039.                     LT_New(Handle,
  1040.                         LA_Type,    LISTVIEW_KIND,
  1041.                         LA_LabelID,    MSG_GLOBAL_NAME_LIST_GAD,
  1042.                         LA_ID,        GAD_NAMELIST,
  1043.                         LA_Chars,    40,
  1044.                         LA_Lines,    4,
  1045.                         GTLV_CallBack,    &ListViewHook,
  1046.                         GTLV_MaxPen,    MaxPen,
  1047.                         LALV_CursorKey,    TRUE,
  1048.                         LALV_MaxGrowX,    50,
  1049.                         LALV_MaxGrowY,    20,
  1050.                         LALV_ResizeX,    TRUE,
  1051.                         LALV_ResizeY,    TRUE,
  1052.  
  1053.                         Kick30 ? LALV_Link : TAG_IGNORE, NIL_LINK,
  1054.                         Kick30 ? TAG_IGNORE : LALV_TextAttr, ~0,
  1055.  
  1056.                         PhoneList ? GTLV_Labels : TAG_IGNORE, PhoneList,
  1057.                     TAG_DONE);
  1058.  
  1059.                     LT_New(Handle,
  1060.                         LA_Type,    LISTVIEW_KIND,
  1061.                         LA_LabelID,    MSG_PHONEPANEL_SETTINGS_TXT,
  1062.                         LA_Lines,    4,
  1063.                         LA_ID,        GAD_EDIT,
  1064.                         LA_NoKey,    TRUE,
  1065.                         GA_Disabled,    TRUE,
  1066.                         GTLV_Labels,    EditList,
  1067.                         GTLV_CallBack,    &EditViewHook,
  1068.  
  1069.                         Kick30 ? TAG_IGNORE : LALV_TextAttr, ~0,
  1070.                     TAG_DONE);
  1071.  
  1072.                     LT_EndGroup(Handle);
  1073.                 }
  1074.  
  1075.                 LT_New(Handle,
  1076.                     LA_Type,    HORIZONTAL_KIND,
  1077.                 TAG_DONE);
  1078.                 {
  1079.                     LT_New(Handle,
  1080.                         LA_Type,    VERTICAL_KIND,
  1081.                     TAG_DONE);
  1082.                     {
  1083.                         LT_New(Handle,
  1084.                             LA_Type,        STRING_KIND,
  1085.                             LA_LabelID,        MSG_PHONEPANEL_BBS_NAME_GAD,
  1086.                             LA_ID,            GAD_NAME,
  1087.                             GTST_MaxChars,        39,
  1088.                             LA_Chars,        40,
  1089.                             GA_Disabled,        TRUE,
  1090.                         TAG_DONE);
  1091.  
  1092.                         LT_New(Handle,
  1093.                             LA_Type,        STRING_KIND,
  1094.                             LA_LabelID,        MSG_PHONEPANEL_COMMENT_GAD,
  1095.                             LA_ID,            GAD_COMMENT,
  1096.                             GTST_MaxChars,        99,
  1097.                             GA_Disabled,        TRUE,
  1098.                         TAG_DONE);
  1099.  
  1100.                         LT_New(Handle,
  1101.                             LA_Type,        STRING_KIND,
  1102.                             LA_LabelID,        MSG_PHONEPANEL_PHONE_NUMBER_GAD,
  1103.                             LA_ID,            GAD_PHONENUMBER,
  1104.                             GTST_MaxChars,        99,
  1105.                             LAST_LastGadget,    TRUE,
  1106.                             GA_Disabled,        TRUE,
  1107.                         TAG_DONE);
  1108.  
  1109.                         LT_EndGroup(Handle);
  1110.                     }
  1111.  
  1112.                     LT_New(Handle,
  1113.                         LA_Type,    VERTICAL_KIND,
  1114.                     TAG_DONE);
  1115.                     {
  1116.                         LT_New(Handle,
  1117.                             LA_Type,    CHECKBOX_KIND,
  1118.                             LA_LabelID,    MSG_PHONEPANEL_QUICK_MENU_GAD,
  1119.                             LA_ID,        GAD_QUICKMENU,
  1120.                             GA_Disabled,    TRUE,
  1121.                         TAG_DONE);
  1122.  
  1123.                         LT_EndGroup(Handle);
  1124.                     }
  1125.  
  1126.                     LT_EndGroup(Handle);
  1127.                 }
  1128.  
  1129.                 LT_EndGroup(Handle);
  1130.             }
  1131.  
  1132.             LT_New(Handle,
  1133.                 LA_Type,VERTICAL_KIND,
  1134.             TAG_DONE);
  1135.             {
  1136.                 LT_New(Handle,
  1137.                     LA_Type,    XBAR_KIND,
  1138.                     LAXB_FullSize,    TRUE,
  1139.                 TAG_DONE);
  1140.  
  1141.                 LT_EndGroup(Handle);
  1142.             }
  1143.  
  1144.             LT_New(Handle,
  1145.                 LA_Type,    VERTICAL_KIND,
  1146.             TAG_DONE);
  1147.             {
  1148.                 LT_New(Handle,
  1149.                     LA_Type,    HORIZONTAL_KIND,
  1150.                     LAGR_SameSize,    TRUE,
  1151.                     LAGR_Spread,    TRUE,
  1152.                 TAG_DONE);
  1153.                 {
  1154.                     LT_New(Handle,
  1155.                         LA_Type,    BUTTON_KIND,
  1156.                         LA_LabelID,    MSG_PHONEPANEL_NEW_ENTRY_GAD,
  1157.                         LA_ID,        GAD_NEWENTRY,
  1158.                         LA_Chars,    MaxChars,
  1159.                     TAG_DONE);
  1160.  
  1161.                     LT_New(Handle,
  1162.                         LA_Type,    BUTTON_KIND,
  1163.                         LA_LabelID,    MSG_PHONEPANEL_CLONE_ENTRY_GAD,
  1164.                         LA_ID,        GAD_CLONEENTRY,
  1165.                         GA_Disabled,    TRUE,
  1166.                     TAG_DONE);
  1167.  
  1168.                     LT_New(Handle,
  1169.                         LA_Type,    BUTTON_KIND,
  1170.                         LA_LabelID,    MSG_PHONEPANEL_REMOVE_ENTRY_GAD,
  1171.                         LA_ID,        GAD_REMOVEENTRY,
  1172.                         GA_Disabled,    TRUE,
  1173.                     TAG_DONE);
  1174.  
  1175.                     LT_New(Handle,
  1176.                         LA_Type,    BUTTON_KIND,
  1177.                         LA_LabelID,    MSG_PHONEPANEL_COPY_CONFIG_GAD,
  1178.                         LA_ID,        GAD_COPYCONFIG,
  1179.                         GA_Disabled,    !NumPhoneEntries,
  1180.                     TAG_DONE);
  1181.  
  1182.                     LT_New(Handle,
  1183.                         LA_Type,    BUTTON_KIND,
  1184.                         LA_LabelID,    MSG_PHONEPANEL_USE_ENTRY_GAD,
  1185.                         LA_ID,        GAD_USEIT,
  1186.                         GA_Disabled,    TRUE,
  1187.                     TAG_DONE);
  1188.  
  1189.                     LT_EndGroup(Handle);
  1190.                 }
  1191.  
  1192.                 LT_New(Handle,
  1193.                     LA_Type,    HORIZONTAL_KIND,
  1194.                     LAGR_SameSize,    TRUE,
  1195.                     LAGR_Spread,    TRUE,
  1196.                 TAG_DONE);
  1197.                 {
  1198.                     LT_New(Handle,
  1199.                         LA_Type,    BUTTON_KIND,
  1200.                         LA_LabelID,    MSG_PHONEPANEL_TAG_GAD,
  1201.                         LA_Chars,    MaxChars,
  1202.                         LA_ID,        GAD_TAG,
  1203.                         GA_Disabled,    TRUE,
  1204.                     TAG_DONE);
  1205.  
  1206.                     LT_New(Handle,
  1207.                         LA_Type,    BUTTON_KIND,
  1208.                         LA_LabelID,    MSG_PHONEPANEL_UNTAG_GAD,
  1209.                         LA_ID,        GAD_UNTAG,
  1210.                         GA_Disabled,    !Count,
  1211.                     TAG_DONE);
  1212.  
  1213.                     LT_New(Handle,
  1214.                         LA_Type,    BUTTON_KIND,
  1215.                         LA_LabelID,    MSG_PHONEPANEL_TAG_ALL_GAD,
  1216.                         LA_ID,        GAD_TAG_ALL,
  1217.                         GA_Disabled,    !NumPhoneEntries,
  1218.                     TAG_DONE);
  1219.  
  1220.                     LT_New(Handle,
  1221.                         LA_Type,    BUTTON_KIND,
  1222.                         LA_LabelID,    MSG_PHONEPANEL_TOGGLE_ALL_GAD,
  1223.                         LA_ID,        GAD_TOGGLE_ALL,
  1224.                         GA_Disabled,    !NumPhoneEntries,
  1225.                     TAG_DONE);
  1226.  
  1227.                     LT_New(Handle,
  1228.                         LA_Type,    BUTTON_KIND,
  1229.                         LA_LabelID,    MSG_PHONEPANEL_UNTAG_ALL_GAD,
  1230.                         LA_ID,        GAD_CLEARLIST,
  1231.                         GA_Disabled,    !Count,
  1232.                     TAG_DONE);
  1233.  
  1234.                     LT_EndGroup(Handle);
  1235.                 }
  1236.  
  1237.                 LT_New(Handle,
  1238.                     LA_Type,VERTICAL_KIND,
  1239.                 TAG_DONE);
  1240.                 {
  1241.                     LT_New(Handle,
  1242.                         LA_Type,    XBAR_KIND,
  1243.                     TAG_DONE);
  1244.  
  1245.                     LT_EndGroup(Handle);
  1246.                 }
  1247.  
  1248.                 LT_New(Handle,
  1249.                     LA_Type,    HORIZONTAL_KIND,
  1250.                     LAGR_SameSize,    TRUE,
  1251.                     LAGR_Spread,    TRUE,
  1252.                 TAG_DONE);
  1253.                 {
  1254.                     LT_New(Handle,
  1255.                         LA_Type,    BUTTON_KIND,
  1256.                         LA_LabelID,    MSG_PHONEPANEL_LOAD_LIST_GAD,
  1257.                         LA_ID,        GAD_LOADLIST,
  1258.                         LA_Chars,    MaxChars,
  1259.                     TAG_DONE);
  1260.  
  1261.                     LT_New(Handle,
  1262.                         LA_Type,    BUTTON_KIND,
  1263.                         LA_LabelID,    MSG_PHONEPANEL_SAVE_LIST_GAD,
  1264.                         LA_ID,        GAD_SAVELIST,
  1265.                         GA_Disabled,    !NumPhoneEntries,
  1266.                     TAG_DONE);
  1267.  
  1268.                     LT_New(Handle,
  1269.                         LA_Type,    BUTTON_KIND,
  1270.                         LA_LabelID,    MSG_PHONEPANEL_PRINT_GAD,
  1271.                         LA_ID,        GAD_PRINT,
  1272.                         GA_Disabled,    !NumPhoneEntries,
  1273.                     TAG_DONE);
  1274.  
  1275.                     LT_New(Handle,
  1276.                         LA_Type,    BUTTON_KIND,
  1277.                         LA_LabelID,    MSG_PHONEPANEL_SORT_LIST_GAD,
  1278.                         LA_ID,        GAD_SORTLIST,
  1279.                         GA_Disabled,    NumPhoneEntries < 2,
  1280.                     TAG_DONE);
  1281.  
  1282.                     LT_New(Handle,
  1283.                         LA_Type,    BUTTON_KIND,
  1284.                         LA_LabelID,    MSG_PHONEPANEL_SET_PASSWORT_GAD,
  1285.                         LA_ID,        GAD_PASSWORD,
  1286.                         GA_Disabled,    !NumPhoneEntries,
  1287.                     TAG_DONE);
  1288.  
  1289.                     LT_EndGroup(Handle);
  1290.                 }
  1291.  
  1292.                 LT_New(Handle,
  1293.                     LA_Type,VERTICAL_KIND,
  1294.                 TAG_DONE);
  1295.                 {
  1296.                     LT_New(Handle,
  1297.                         LA_Type,    XBAR_KIND,
  1298.                         LAXB_FullSize,    TRUE,
  1299.                     TAG_DONE);
  1300.  
  1301.                     LT_EndGroup(Handle);
  1302.                 }
  1303.  
  1304.                 LT_New(Handle,
  1305.                     LA_Type,    HORIZONTAL_KIND,
  1306.                 TAG_DONE);
  1307.                 {
  1308.                     LT_New(Handle,
  1309.                         LA_Type,    BUTTON_KIND,
  1310.                         LA_LabelID,    MSG_PHONEPANEL_DIAL_LIST_GAD,
  1311.                         LA_ID,        GAD_DIALLIST,
  1312.                         LABT_ReturnKey,    TRUE,
  1313.                         LABT_ExtraFat,    TRUE,
  1314.                         GA_Disabled,    !Count || (Online && !Config -> MiscConfig -> ProtectiveMode),
  1315.                     TAG_DONE);
  1316.  
  1317.                     LT_EndGroup(Handle);
  1318.                 }
  1319.  
  1320.                 LT_EndGroup(Handle);
  1321.             }
  1322.  
  1323.             LT_EndGroup(Handle);
  1324.         }
  1325.  
  1326.         Bounds . Left    = WindowLeft + Window -> LeftEdge;
  1327.         Bounds . Top    = WindowTop + Window -> TopEdge;
  1328.         Bounds . Width    = WindowWidth;
  1329.         Bounds . Height    = WindowHeight;
  1330.  
  1331.         if(PhoneWindow = LT_Layout(Handle,LocaleString(MSG_PHONEPANEL_PHONEBOOK_TXT),&Bounds,0,0,IDCMP_CLOSEWINDOW,0,
  1332.             LAWN_HelpHook,        &GuideHook,
  1333. //            LAWN_Parent,        Window,
  1334.             WA_DepthGadget,        TRUE,
  1335.             WA_CloseGadget,        TRUE,
  1336.             WA_DragBar,        TRUE,
  1337.             WA_RMBTrap,        TRUE,
  1338.             WA_Activate,        TRUE,
  1339.         TAG_DONE))
  1340.         {
  1341.             struct IntuiMessage    *Message;
  1342.             BOOLEAN             Done = FALSE;
  1343.             ULONG             MsgClass,
  1344.                          MsgQualifier,
  1345.                          CompleteQualifier;
  1346.             UWORD             MsgCode;
  1347.             struct Gadget        *MsgGadget;
  1348.  
  1349.             BYTE             ClickAction;
  1350.  
  1351.             UBYTE             DummyBuffer[MAX_FILENAME_LENGTH],
  1352.                         *DummyChar;
  1353.  
  1354.             LONG             Selected = ~0,i,
  1355.                          MsgGadgetID;
  1356.  
  1357.             struct FileRequester    *FileRequest;
  1358.             WORD             Vanilla;
  1359.  
  1360.             GuideContext(CONTEXT_PHONEBOOK);
  1361.  
  1362.             PushWindow(PhoneWindow);
  1363.  
  1364.             SetPanelState(Handle,PhoneList,Count,Selected);
  1365.  
  1366.             do
  1367.             {
  1368.                 if(Wait(PORTMASK(PhoneWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  1369.                 {
  1370.                     FreeDialList(TRUE);
  1371.  
  1372.                     break;
  1373.                 }
  1374.  
  1375.                 while(Message = (struct IntuiMessage *)GT_GetIMsg(PhoneWindow -> UserPort))
  1376.                 {
  1377.                     MsgClass    = Message -> Class;
  1378.                     MsgQualifier    = Message -> Qualifier;
  1379.                     MsgCode        = Message -> Code;
  1380.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  1381.  
  1382.                     GT_ReplyIMsg(Message);
  1383.  
  1384.                     CompleteQualifier = MsgQualifier;
  1385.  
  1386.                     if(MsgClass == IDCMP_RAWKEY && (MsgCode == CURSORUP || MsgCode == CURSORDOWN))
  1387.                         MsgQualifier &= ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT);
  1388.  
  1389.                     LT_HandleInput(Handle,CompleteQualifier,&MsgClass,&MsgCode,&MsgGadget);
  1390.  
  1391.                     if(MsgClass == IDCMP_GADGETUP || MsgClass == IDCMP_IDCMPUPDATE)
  1392.                         MsgGadgetID = MsgGadget -> GadgetID;
  1393.                     else
  1394.                         MsgGadgetID = -1;
  1395.  
  1396.                     Vanilla = LT_GetCode(CompleteQualifier,MsgClass,MsgCode,MsgGadget);
  1397.  
  1398.                     switch(Vanilla)
  1399.                     {
  1400.                         case ' ':
  1401.  
  1402.                             if(Selected != -1)
  1403.                             {
  1404.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1405.                                     GTLV_Labels,    ~0,
  1406.                                 TAG_DONE);
  1407.  
  1408.                                 if(Phonebook[Selected] -> Count == -1)
  1409.                                 {
  1410.                                     Phonebook[Selected] -> Count = Count++;
  1411.  
  1412.                                     SPrintf(Phonebook[Selected] -> Node -> LocalName,"%3ld - %s",Count,Phonebook[Selected] -> Header -> Name);
  1413.  
  1414.                                     LT_PressButton(Handle,GAD_TAG);
  1415.                                 }
  1416.                                 else
  1417.                                 {
  1418.                                     RemoveDialEntry(Selected);
  1419.  
  1420.                                     Count--;
  1421.  
  1422.                                     LT_PressButton(Handle,GAD_UNTAG);
  1423.                                 }
  1424.  
  1425.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1426.                             }
  1427.  
  1428.                             break;
  1429.  
  1430.                         case 127:
  1431.  
  1432.                             if(CompleteQualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
  1433.                             {
  1434.                                 if(Count > 0)
  1435.                                 {
  1436.                                     MsgClass    = IDCMP_GADGETUP;
  1437.                                     MsgGadgetID    = GAD_CLEARLIST;
  1438.                                 }
  1439.                             }
  1440.                             else
  1441.                             {
  1442.                                 if(Selected != -1 && Phonebook[Selected] -> Count != -1)
  1443.                                 {
  1444.                                     MsgClass    = IDCMP_GADGETUP;
  1445.                                     MsgGadgetID    = GAD_UNTAG;
  1446.                                 }
  1447.                             }
  1448.  
  1449.                             break;
  1450.                     }
  1451.  
  1452.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  1453.                     {
  1454.                         FreeDialList(TRUE);
  1455.  
  1456.                         Done = TRUE;
  1457.                     }
  1458.  
  1459.                     if(MsgClass == IDCMP_GADGETUP)
  1460.                     {
  1461.                         switch(MsgGadgetID)
  1462.                         {
  1463.                             case GAD_TOGGLE_ALL:
  1464.                             {
  1465.                                 LONG LocalCount = 0;
  1466.  
  1467.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1468.                                     GTLV_Labels,    ~0,
  1469.                                 TAG_DONE);
  1470.  
  1471.                                 for(i = 0 ; i < NumPhoneEntries ; i++)
  1472.                                 {
  1473.                                     if(Phonebook[i] -> Count == -1)
  1474.                                     {
  1475.                                         Phonebook[i] -> Count = LocalCount++;
  1476.  
  1477.                                         SPrintf(Phonebook[i] -> Node -> LocalName,"%3ld - %s",LocalCount,Phonebook[i] -> Header -> Name);
  1478.                                     }
  1479.                                     else
  1480.                                         RemoveDialEntry(i);
  1481.                                 }
  1482.  
  1483.                                 Count = LocalCount;
  1484.  
  1485.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1486.                                     GTLV_Labels,    PhoneList,
  1487.                                 TAG_DONE);
  1488.  
  1489.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1490.  
  1491.                                 break;
  1492.                             }
  1493.  
  1494.                             case GAD_TAG_ALL:
  1495.  
  1496.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1497.                                     GTLV_Labels,    ~0,
  1498.                                 TAG_DONE);
  1499.  
  1500.                                 for(i = 0 ; i < NumPhoneEntries ; i++)
  1501.                                 {
  1502.                                     if(Phonebook[i] -> Count == -1)
  1503.                                     {
  1504.                                         Phonebook[i] -> Count = Count++;
  1505.  
  1506.                                         SPrintf(Phonebook[i] -> Node -> LocalName,"%3ld - %s",Count,Phonebook[i] -> Header -> Name);
  1507.                                     }
  1508.                                 }
  1509.  
  1510.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1511.                                     GTLV_Labels,    PhoneList,
  1512.                                 TAG_DONE);
  1513.  
  1514.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1515.  
  1516.                                 break;
  1517.  
  1518.                             case GAD_TAG:
  1519.  
  1520.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1521.                                     GTLV_Labels,    ~0,
  1522.                                 TAG_DONE);
  1523.  
  1524.                                 Phonebook[Selected] -> Count = Count++;
  1525.  
  1526.                                 SPrintf(Phonebook[Selected] -> Node -> LocalName,"%3ld - %s",Count,Phonebook[Selected] -> Header -> Name);
  1527.  
  1528.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1529.                                     GTLV_Labels,    PhoneList,
  1530.                                 TAG_DONE);
  1531.  
  1532.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1533.  
  1534.                                 break;
  1535.  
  1536.                             case GAD_UNTAG:
  1537.  
  1538.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1539.                                     GTLV_Labels,    ~0,
  1540.                                 TAG_DONE);
  1541.  
  1542.                                 RemoveDialEntry(Selected);
  1543.  
  1544.                                 Count--;
  1545.  
  1546.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1547.                                     GTLV_Labels,    PhoneList,
  1548.                                 TAG_DONE);
  1549.  
  1550.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1551.  
  1552.                                 break;
  1553.  
  1554.                             case GAD_NAMELIST:
  1555.  
  1556.                                 Selected = MsgCode;
  1557.  
  1558.                                 if(Phonebook[Selected] -> Header -> Number[0] && Phonebook[Selected] -> Header -> Name[0])
  1559.                                 {
  1560.                                     if(MsgQualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
  1561.                                         ClickAction = CLICK_TOGGLE;
  1562.                                     else
  1563.                                         ClickAction = CLICK_SELECT;
  1564.                                 }
  1565.                                 else
  1566.                                     ClickAction = CLICK_SELECT;
  1567.  
  1568.                                 if(ClickAction == CLICK_TOGGLE)
  1569.                                 {
  1570.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  1571.                                         GTLV_Labels,    ~0,
  1572.                                     TAG_DONE);
  1573.  
  1574.                                     if(Phonebook[Selected] -> Count == -1)
  1575.                                     {
  1576.                                         Phonebook[Selected] -> Count = Count++;
  1577.  
  1578.                                         SPrintf(Phonebook[Selected] -> Node -> LocalName,"%3ld - %s",Count,Phonebook[Selected] -> Header -> Name);
  1579.                                     }
  1580.                                     else
  1581.                                     {
  1582.                                         RemoveDialEntry(Selected);
  1583.  
  1584.                                         Count--;
  1585.                                     }
  1586.  
  1587.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  1588.                                         GTLV_Labels,    PhoneList,
  1589.                                     TAG_DONE);
  1590.                                 }
  1591.  
  1592.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1593.  
  1594.                                 break;
  1595.  
  1596.                             case GAD_CLEARLIST:
  1597.  
  1598.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1599.                                     GTLV_Labels,    ~0,
  1600.                                 TAG_DONE);
  1601.  
  1602.                                 Count = 0;
  1603.  
  1604.                                 for(i = 0 ; i < NumPhoneEntries ; i++)
  1605.                                 {
  1606.                                     SPrintf(Phonebook[i] -> Node -> LocalName,"      %s",Phonebook[i] -> Header -> Name);
  1607.  
  1608.                                     Phonebook[i] -> Count = -1;
  1609.                                 }
  1610.  
  1611.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1612.                                     GTLV_Labels,    PhoneList,
  1613.                                 TAG_DONE);
  1614.  
  1615.                                 SetPanelState(Handle,PhoneList,Count,Selected);
  1616.  
  1617.                                 break;
  1618.  
  1619.                             case GAD_PRINT:
  1620.  
  1621.                                 LT_LockWindow(PhoneWindow);
  1622.  
  1623.                                 PrintPanel(PhoneWindow,PhoneList,Count);
  1624.  
  1625.                                 LT_UnlockWindow(PhoneWindow);
  1626.  
  1627.                                 LT_ShowWindow(Handle,TRUE);
  1628.  
  1629.                                 break;
  1630.  
  1631.                             case GAD_USEIT:
  1632.  
  1633.                                 if(Selected != ~0)
  1634.                                 {
  1635.                                     SaveConfig(Config,PrivateConfig);
  1636.  
  1637.                                     SaveConfig(Phonebook[Selected] -> Config,Config);
  1638.  
  1639.                                     strcpy(Password,Phonebook[Selected] -> Header -> Password);
  1640.                                     strcpy(UserName,Phonebook[Selected] -> Header -> UserName);
  1641.  
  1642.                                     ConfigSetup();
  1643.  
  1644.                                     Done = TRUE;
  1645.  
  1646.                                     ConfigChanged = FALSE;
  1647.                                 }
  1648.  
  1649.                                 break;
  1650.  
  1651.                             case GAD_NEWENTRY:
  1652.  
  1653.                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1654.                                     GTLV_Labels,    ~0,
  1655.                                 TAG_DONE);
  1656.  
  1657.                                 if(PhoneList)
  1658.                                 {
  1659.                                     DeletePhoneList(PhoneList);
  1660.  
  1661.                                     PhoneList = NULL;
  1662.                                 }
  1663.  
  1664.                                 if(NewPhoneEntry())
  1665.                                 {
  1666.                                     if(PhoneList = CreatePhoneList())
  1667.                                     {
  1668.                                         Selected = NumPhoneEntries - 1;
  1669.  
  1670.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1671.                                             GTLV_Labels,        PhoneList,
  1672.                                             GTLV_Selected,        Selected,
  1673.                                             GTLV_Top,        Selected,
  1674.                                             GTLV_MakeVisible,    Selected,
  1675.                                         TAG_DONE);
  1676.  
  1677.                                         SetPanelState(Handle,PhoneList,Count,Selected);
  1678.  
  1679.                                         LT_Activate(Handle,GAD_NAME);
  1680.  
  1681.                                         RebuildMenu = PhonebookChanged = TRUE;
  1682.                                     }
  1683.                                     else
  1684.                                         goto ClearList;
  1685.                                 }
  1686.                                 else
  1687.                                     goto ClearList;
  1688.  
  1689.                                 break;
  1690.  
  1691.                             case GAD_CLONEENTRY:
  1692.  
  1693.                                 if(Selected != ~0)
  1694.                                 {
  1695.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  1696.                                         GTLV_Labels,    ~0,
  1697.                                     TAG_DONE);
  1698.  
  1699.                                     if(PhoneList)
  1700.                                     {
  1701.                                         DeletePhoneList(PhoneList);
  1702.  
  1703.                                         PhoneList = NULL;
  1704.                                     }
  1705.  
  1706.                                     if(NewPhoneEntry())
  1707.                                     {
  1708.                                         if(PhoneList = CreatePhoneList())
  1709.                                         {
  1710.                                             LONG Tmp = Selected,i;
  1711.  
  1712.                                             Selected = NumPhoneEntries - 1;
  1713.  
  1714.                                             CopyMem(Phonebook[Tmp] -> Header,Phonebook[Selected] -> Header,sizeof(struct PhoneHeader));
  1715.  
  1716.                                             Phonebook[Selected] -> Header -> QuickMenu = FALSE;
  1717.  
  1718.                                             SPrintf(Phonebook[Selected] -> Node -> LocalName,"      %s",Phonebook[Selected] -> Header -> Name);
  1719.  
  1720.                                             FreeTimeDateList((struct List *)&Phonebook[Selected] -> TimeDateList);
  1721.  
  1722.                                             CopyTimeDateList((struct List *)&Phonebook[Tmp] -> TimeDateList,(struct List *)&Phonebook[Selected] -> TimeDateList,FALSE);
  1723.  
  1724.                                             LT_SetAttributes(Handle,GAD_NAMELIST,
  1725.                                                 GTLV_Labels,        PhoneList,
  1726.                                                 GTLV_Selected,        Selected,
  1727.                                                 GTLV_Top,        Selected,
  1728.                                                 GTLV_MakeVisible,    Selected,
  1729.                                             TAG_DONE);
  1730.  
  1731.                                             SetPanelState(Handle,PhoneList,Count,Selected);
  1732.  
  1733.                                                 /* Allocate space for the config data. */
  1734.  
  1735.                                             for(i = PREF_SERIAL ; i <= PREF_TRANSFER ; i++)
  1736.                                             {
  1737.                                                 if(GetConfigEntry(Phonebook[Tmp] -> Config,i))
  1738.                                                     CreateConfigEntry(Phonebook[Selected] -> Config,i);
  1739.                                             }
  1740.  
  1741.                                                 /* Copy the data. */
  1742.  
  1743.                                             SaveConfig(Phonebook[Tmp] -> Config,Phonebook[Selected] -> Config);
  1744.  
  1745.                                             RebuildMenu = PhonebookChanged = TRUE;
  1746.  
  1747.                                             LT_SetAttributes(Handle,GAD_EDIT,
  1748.                                                 GTLV_Labels,    ~0,
  1749.                                             TAG_DONE);
  1750.  
  1751.                                             UpdateEditList(Phonebook[Selected] -> Config);
  1752.  
  1753.                                             LT_SetAttributes(Handle,GAD_EDIT,
  1754.                                                 GTLV_Labels,    EditList,
  1755.                                             TAG_DONE);
  1756.                                         }
  1757.                                         else
  1758.                                             goto ClearList;
  1759.                                     }
  1760.                                     else
  1761.                                         goto ClearList;
  1762.                                 }
  1763.  
  1764.                                 break;
  1765.  
  1766.                             case GAD_REMOVEENTRY:
  1767.  
  1768.                                 if(Selected != ~0)
  1769.                                 {
  1770.                                     if(Phonebook[Selected] == ChosenEntry)
  1771.                                         MyEasyRequest(PhoneWindow,LocaleString(MSG_PHONEPANEL_PHONE_ENTRY_IN_USE_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT));
  1772.                                     else
  1773.                                     {
  1774.                                         RebuildMenu = PhonebookChanged = TRUE;
  1775.  
  1776.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1777.                                             GTLV_Labels,~0,
  1778.                                         TAG_DONE);
  1779.  
  1780.                                         if(PhoneList)
  1781.                                         {
  1782.                                             DeletePhoneList(PhoneList);
  1783.  
  1784.                                             PhoneList = NULL;
  1785.                                         }
  1786.  
  1787.                                         if(Phonebook[Selected] -> Count != -1)
  1788.                                         {
  1789.                                             RemoveDialEntry(Selected);
  1790.  
  1791.                                             Count--;
  1792.                                         }
  1793.  
  1794.                                         RemPhoneEntry(Selected);
  1795.  
  1796.                                         if(NumPhoneEntries > 0)
  1797.                                         {
  1798.                                             if(PhoneList = CreatePhoneList())
  1799.                                             {
  1800.                                                 if(Selected == NumPhoneEntries)
  1801.                                                     Selected--;
  1802.  
  1803.                                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  1804.                                                     GTLV_Labels,    PhoneList,
  1805.                                                     GTLV_Selected,    Selected,
  1806.                                                 TAG_DONE);
  1807.  
  1808.                                                 LT_SetAttributes(Handle,GAD_NAME,
  1809.                                                     GTST_String,    Phonebook[Selected] -> Header -> Name,
  1810.                                                     GA_Disabled,    FALSE,
  1811.                                                 TAG_DONE);
  1812.  
  1813.                                                 LT_SetAttributes(Handle,GAD_COMMENT,
  1814.                                                     GTST_String,    Phonebook[Selected] -> Header -> Comment,
  1815.                                                     GA_Disabled,    FALSE,
  1816.                                                 TAG_DONE);
  1817.  
  1818.                                                 LT_SetAttributes(Handle,GAD_PHONENUMBER,
  1819.                                                     GTST_String,    Phonebook[Selected] -> Header -> Number,
  1820.                                                     GA_Disabled,    FALSE,
  1821.                                                 TAG_DONE);
  1822.  
  1823.                                                 LT_SetAttributes(Handle,GAD_QUICKMENU,
  1824.                                                     GTCB_Checked,    Phonebook[Selected] -> Header -> QuickMenu,
  1825.                                                     GA_Disabled,    FALSE,
  1826.                                                 TAG_DONE);
  1827.  
  1828.                                                 LT_SetAttributes(Handle,GAD_EDIT,
  1829.                                                     GTLV_Labels,    ~0,
  1830.                                                 TAG_DONE);
  1831.  
  1832.                                                 UpdateEditList(Phonebook[Selected] -> Config);
  1833.  
  1834.                                                 LT_SetAttributes(Handle,GAD_EDIT,
  1835.                                                     GTLV_Labels,    EditList,
  1836.                                                     GA_Disabled,    FALSE,
  1837.                                                 TAG_DONE);
  1838.                                             }
  1839.                                             else
  1840.                                                 goto ClearList;
  1841.  
  1842.                                             SetPanelState(Handle,PhoneList,Count,Selected);
  1843.                                         }
  1844.                                         else
  1845.                                         {
  1846. ClearList:                                        LT_SetAttributes(Handle,GAD_NAMELIST,
  1847.                                                 GTLV_Labels,    &EmptyList,
  1848.                                                 GTLV_Selected,    ~0,
  1849.                                             TAG_DONE);
  1850.  
  1851.                                             Selected = ~0;
  1852.  
  1853.                                             Count = 0;
  1854.  
  1855.                                             SetPanelState(Handle,PhoneList,Count,Selected);
  1856.                                         }
  1857.                                     }
  1858.                                 }
  1859.  
  1860.                                 break;
  1861.  
  1862.                             case GAD_NAME:
  1863.  
  1864.                                 if(Selected != ~0)
  1865.                                 {
  1866.                                     strcpy(Phonebook[Selected] -> Header -> Name,(STRPTR)LT_GetAttributes(Handle,GAD_NAME,TAG_DONE));
  1867.  
  1868.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  1869.                                         GTLV_Labels,~0,
  1870.                                     TAG_DONE);
  1871.  
  1872.                                     if(PhoneList)
  1873.                                         DeletePhoneList(PhoneList);
  1874.  
  1875.                                     if(PhoneList = CreatePhoneList())
  1876.                                     {
  1877.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1878.                                             GTLV_Labels,        PhoneList,
  1879.                                             GTLV_Selected,        Selected,
  1880.                                             GTLV_Top,        Selected,
  1881.                                             GTLV_MakeVisible,    Selected,
  1882.                                         TAG_DONE);
  1883.                                     }
  1884.  
  1885.                                     if(!Phonebook[Selected] -> Header -> Name[0])
  1886.                                     {
  1887.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1888.                                             GTLV_Labels,    ~0,
  1889.                                         TAG_DONE);
  1890.  
  1891.                                         if(Phonebook[Selected] -> Count != -1)
  1892.                                         {
  1893.                                             RemoveDialEntry(Selected);
  1894.  
  1895.                                             Count--;
  1896.                                         }
  1897.  
  1898.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1899.                                             GTLV_Labels,        PhoneList,
  1900.                                             GTLV_Selected,        Selected,
  1901.                                             GTLV_Top,        Selected,
  1902.                                             GTLV_MakeVisible,    Selected,
  1903.                                         TAG_DONE);
  1904.                                     }
  1905.  
  1906.                                     SetPanelState(Handle,PhoneList,Count,Selected);
  1907.  
  1908.                                     RebuildMenu = PhonebookChanged = TRUE;
  1909.  
  1910.                                     if(MsgCode == '\r')
  1911.                                         LT_Activate(Handle,GAD_COMMENT);
  1912.                                 }
  1913.  
  1914.                                 break;
  1915.  
  1916.                             case GAD_COMMENT:
  1917.  
  1918.                                 if(Selected != ~0)
  1919.                                 {
  1920.                                     strcpy(Phonebook[Selected] -> Header -> Comment,(STRPTR)LT_GetAttributes(Handle,GAD_COMMENT,TAG_DONE));
  1921.  
  1922.                                     PhonebookChanged = TRUE;
  1923.  
  1924.                                     if(MsgCode == '\r')
  1925.                                         LT_Activate(Handle,GAD_PHONENUMBER);
  1926.                                 }
  1927.  
  1928.                                 break;
  1929.  
  1930.                             case GAD_QUICKMENU:
  1931.  
  1932.                                 if(Selected != ~0)
  1933.                                 {
  1934.                                     if(Phonebook[Selected] -> Header -> QuickMenu != MsgCode)
  1935.                                     {
  1936.                                         Phonebook[Selected] -> Header -> QuickMenu = MsgCode;
  1937.  
  1938.                                         RebuildMenu = PhonebookChanged = TRUE;
  1939.                                     }
  1940.                                 }
  1941.  
  1942.                                 break;
  1943.  
  1944.                             case GAD_PHONENUMBER:
  1945.  
  1946.                                 if(Selected != ~0)
  1947.                                 {
  1948.                                     strcpy(Phonebook[Selected] -> Header -> Number,(STRPTR)LT_GetAttributes(Handle,GAD_PHONENUMBER,TAG_DONE));
  1949.  
  1950.                                     PhonebookChanged = TRUE;
  1951.  
  1952.                                     if(!Phonebook[Selected] -> Header -> Number[0])
  1953.                                     {
  1954.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1955.                                             GTLV_Labels,    ~0,
  1956.                                         TAG_DONE);
  1957.  
  1958.                                         if(Phonebook[Selected] -> Count != -1)
  1959.                                         {
  1960.                                             RemoveDialEntry(Selected);
  1961.  
  1962.                                             Count--;
  1963.                                         }
  1964.  
  1965.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1966.                                             GTLV_Labels,        PhoneList,
  1967.                                         TAG_DONE);
  1968.                                     }
  1969.  
  1970.                                     SetPanelState(Handle,PhoneList,Count,Selected);
  1971.                                 }
  1972.  
  1973.                                 break;
  1974.  
  1975.                             case GAD_LOADLIST:
  1976.  
  1977.                                 LT_LockWindow(PhoneWindow);
  1978.  
  1979.                                 if(ChosenEntry)
  1980.                                     MyEasyRequest(PhoneWindow,LocaleString(MSG_PHONEPANEL_PHONE_ENTRY_IN_USE_LOAD_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT));
  1981.                                 else
  1982.                                 {
  1983.                                     SplitFileName(LastPhone,&DummyChar,DummyBuffer);
  1984.  
  1985.                                     if(FileRequest = GetFile(PhoneWindow,LocaleString(MSG_PHONEPANEL_LOAD_PHONEBOOK_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_LOAD_TXT),TRUE))
  1986.                                     {
  1987.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  1988.                                             GTLV_Labels,    ~0,
  1989.                                             GTLV_Selected,    ~0,
  1990.                                         TAG_DONE);
  1991.  
  1992.                                         if(PhoneList)
  1993.                                             DeletePhoneList(PhoneList);
  1994.  
  1995.                                         if(!LoadPhonebook(DummyBuffer))
  1996.                                             ShowError(PhoneWindow,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  1997.                                         else
  1998.                                         {
  1999.                                             strcpy(LastPhone,DummyBuffer);
  2000.  
  2001.                                             PhonebookChanged = FALSE;
  2002.  
  2003.                                             RebuildMenu = TRUE;
  2004.                                         }
  2005.  
  2006.                                         if(PhoneList = CreatePhoneList())
  2007.                                         {
  2008.                                             LT_SetAttributes(Handle,GAD_NAMELIST,
  2009.                                                 GTLV_Labels,    PhoneList,
  2010.                                                 GA_Disabled,    FALSE,
  2011.                                             TAG_DONE);
  2012.  
  2013.                                             FreeDialList(TRUE);
  2014.                                         }
  2015.                                         else
  2016.                                         {
  2017.                                             LT_SetAttributes(Handle,GAD_NAMELIST,
  2018.                                                 GTLV_Labels,    &EmptyList,
  2019.                                                 GA_Disabled,    TRUE,
  2020.                                             TAG_DONE);
  2021.                                         }
  2022.  
  2023.                                         Selected = ~0;
  2024.  
  2025.                                         Count = 0;
  2026.  
  2027.                                         SetPanelState(Handle,PhoneList,Count,Selected);
  2028.  
  2029.                                         FreeAslRequest(FileRequest);
  2030.                                     }
  2031.                                 }
  2032.  
  2033.                                 LT_UnlockWindow(PhoneWindow);
  2034.  
  2035.                                 break;
  2036.  
  2037.                             case GAD_SORTLIST:
  2038.  
  2039.                                 if(NumPhoneEntries > 1)
  2040.                                 {
  2041.                                     RebuildMenu = PhonebookChanged = TRUE;
  2042.  
  2043.                                     LT_LockWindow(PhoneWindow);
  2044.  
  2045.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  2046.                                         GTLV_Labels,    ~0,
  2047.                                         GTLV_Selected,    ~0,
  2048.                                     TAG_DONE);
  2049.  
  2050.                                     Selected = ~0;
  2051.  
  2052.                                     SetPanelState(Handle,PhoneList,Count,Selected);
  2053.  
  2054.                                     if(PhoneList)
  2055.                                         DeletePhoneList(PhoneList);
  2056.  
  2057.                                     SortPhoneEntries();
  2058.  
  2059.                                     if(PhoneList = CreatePhoneList())
  2060.                                     {
  2061.                                         LT_SetAttributes(Handle,GAD_NAMELIST,
  2062.                                             GTLV_Labels,    PhoneList,
  2063.                                             GTLV_Selected,    ~0,
  2064.                                         TAG_DONE);
  2065.                                     }
  2066.                                     else
  2067.                                         Count = 0;
  2068.  
  2069.                                     LT_UnlockWindow(PhoneWindow);
  2070.                                 }
  2071.  
  2072.                                 break;
  2073.  
  2074.                             case GAD_SAVELIST:
  2075.  
  2076.                                 if(NumPhoneEntries)
  2077.                                 {
  2078.                                     SplitFileName(LastPhone,&DummyChar,DummyBuffer);
  2079.  
  2080.                                     LT_LockWindow(PhoneWindow);
  2081.  
  2082.                                     if(FileRequest = GetFile(PhoneWindow,LocaleString(MSG_PHONEPANEL_SAVE_PHONEBOOK_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",TRUE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SAVE_TXT),TRUE))
  2083.                                     {
  2084.                                         if(!SavePhonebook(DummyBuffer))
  2085.                                             ShowError(PhoneWindow,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  2086.                                         else
  2087.                                         {
  2088.                                             strcpy(LastPhone,DummyBuffer);
  2089.  
  2090.                                             PhonebookChanged = FALSE;
  2091.                                         }
  2092.  
  2093.                                         FreeAslRequest(FileRequest);
  2094.                                     }
  2095.  
  2096.                                     LT_UnlockWindow(PhoneWindow);
  2097.                                 }
  2098.  
  2099.                                 break;
  2100.  
  2101.                             case GAD_COPYCONFIG:
  2102.  
  2103.                                 LT_LockWindow(PhoneWindow);
  2104.  
  2105.                                 if(Selected == ~0)
  2106.                                     PhonebookChanged |= CopyPanel(NULL,Count > 0);
  2107.                                 else
  2108.                                 {
  2109.                                     PhonebookChanged |= CopyPanel(Phonebook[Selected] -> Config,Count > 0);
  2110.  
  2111.                                     LT_SetAttributes(Handle,GAD_EDIT,
  2112.                                         GTLV_Labels,    ~0,
  2113.                                     TAG_DONE);
  2114.  
  2115.                                     UpdateEditList(Phonebook[Selected] -> Config);
  2116.  
  2117.                                     LT_SetAttributes(Handle,GAD_EDIT,
  2118.                                         GTLV_Labels,    EditList,
  2119.                                     TAG_DONE);
  2120.                                 }
  2121.  
  2122.                                 LT_UnlockWindow(PhoneWindow);
  2123.  
  2124.                                 LT_ShowWindow(Handle,TRUE);
  2125.  
  2126.                                 break;
  2127.  
  2128.                             case GAD_PASSWORD:
  2129.  
  2130.                                 LT_LockWindow(PhoneWindow);
  2131.  
  2132.                                 {
  2133.                                     UBYTE SomeBuffer[30];
  2134.  
  2135.                                     memset(SomeBuffer,0,21);
  2136.  
  2137.                                     PhonePasswordUsed = FALSE;
  2138.  
  2139.                                     if(GetString(FALSE,TRUE,21,LocaleString(MSG_PHONEPANEL_PLEASE_ENTER_PASSWORD_TXT),SomeBuffer))
  2140.                                     {
  2141.                                         SomeBuffer[20] = 0;
  2142.  
  2143.                                         PhonebookChanged = TRUE;
  2144.  
  2145.                                         if(SomeBuffer[0])
  2146.                                         {
  2147.                                             UBYTE OtherBuffer[30];
  2148.  
  2149.                                             memset(OtherBuffer,0,21);
  2150.  
  2151.                                             if(GetString(FALSE,TRUE,21,LocaleString(MSG_PHONEPANEL_PLEASE_REPEAT_PASSWORD_TXT),OtherBuffer))
  2152.                                             {
  2153.                                                 OtherBuffer[20] = 0;
  2154.  
  2155.                                                 if(!memcmp(OtherBuffer,SomeBuffer,20))
  2156.                                                 {
  2157.                                                     Encrypt(OtherBuffer,20,PhonePassword,OtherBuffer,strlen(OtherBuffer));
  2158.  
  2159.                                                     PhonePasswordUsed = TRUE;
  2160.                                                 }
  2161.                                                 else
  2162.                                                     MyEasyRequest(PhoneWindow,LocaleString(MSG_PHONEPANEL_ERROR_ENTERING_PASSWORD_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT));
  2163.                                             }
  2164.                                             else
  2165.                                                 MyEasyRequest(PhoneWindow,LocaleString(MSG_PHONEPANEL_ERROR_ENTERING_PASSWORD_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT));
  2166.                                         }
  2167.                                     }
  2168.                                 }
  2169.  
  2170.                                 LT_ShowWindow(Handle,TRUE);
  2171.  
  2172.                                 LT_UnlockWindow(PhoneWindow);
  2173.                                 break;
  2174.  
  2175.                             case GAD_EDIT:
  2176.  
  2177.                                 if(Selected != ~0)
  2178.                                 {
  2179.                                     LT_LockWindow(PhoneWindow);
  2180.  
  2181.                                     switch(MsgCode)
  2182.                                     {
  2183.                                         case EDIT_RATES:
  2184.  
  2185.                                             if(Phonebook[Selected] == ChosenEntry)
  2186.                                                 MyEasyRequest(PhoneWindow,LocaleString(MSG_PHONEPANEL_PHONE_ENTRY_IN_USE_EDIT_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),DummyBuffer);
  2187.                                             else
  2188.                                             {
  2189.                                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  2190.                                                     GTLV_Labels,    ~0,
  2191.                                                 TAG_DONE);
  2192.  
  2193.                                                 PhonebookChanged |= RatePanel(PhoneWindow,PhoneList,Phonebook[Selected],NULL);
  2194.  
  2195.                                                 LT_SetAttributes(Handle,GAD_NAMELIST,
  2196.                                                     GTLV_Labels,    PhoneList,
  2197.                                                 TAG_DONE);
  2198.                                             }
  2199.  
  2200.                                             break;
  2201.  
  2202.                                         case EDIT_PASSWORD:
  2203.  
  2204.                                             PhonebookChanged |= PasswordUserPanel(Phonebook[Selected]);
  2205.                                             break;
  2206.  
  2207.                                         default:
  2208.  
  2209.                                             PhonebookChanged |= EditConfig(Phonebook[Selected] -> Config,MsgCode,MsgQualifier,PhoneWindow);
  2210.                                             break;
  2211.                                     }
  2212.  
  2213.                                     LT_SetAttributes(Handle,GAD_EDIT,
  2214.                                         GTLV_Labels,    ~0,
  2215.                                     TAG_DONE);
  2216.  
  2217.                                     UpdateEditList(Phonebook[Selected] -> Config);
  2218.  
  2219.                                     LT_SetAttributes(Handle,GAD_EDIT,
  2220.                                         GTLV_Labels,    EditList,
  2221.                                     TAG_DONE);
  2222.  
  2223.                                     LT_UnlockWindow(PhoneWindow);
  2224.  
  2225.                                     LT_ShowWindow(Handle,TRUE);
  2226.                                 }
  2227.  
  2228.                                 break;
  2229.  
  2230.                             case GAD_DIALLIST:
  2231.  
  2232.                                 if(!Count && Selected != ~0)
  2233.                                 {
  2234.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  2235.                                         GTLV_Labels,    ~0,
  2236.                                     TAG_DONE);
  2237.  
  2238.                                     SPrintf(Phonebook[Selected] -> Node -> LocalName,"      %s",Phonebook[Selected] -> Header -> Name);
  2239.  
  2240.                                     Phonebook[Selected] -> Count = Count++;
  2241.  
  2242.                                     LT_SetAttributes(Handle,GAD_NAMELIST,
  2243.                                         GTLV_Labels,    PhoneList,
  2244.                                     TAG_DONE);
  2245.                                 }
  2246.  
  2247.                                     /* If the modem is still online, provide help. */
  2248.  
  2249.                                 if(Count > 0 && AskDial(PhoneWindow))
  2250.                                 {
  2251.                                     DialTheList    = TRUE;
  2252.                                     Done        = TRUE;
  2253.                                 }
  2254.  
  2255.                                 break;
  2256.                         }
  2257.                     }
  2258.  
  2259.                     if(MsgClass == IDCMP_IDCMPUPDATE && MsgGadgetID == GAD_NAMELIST)
  2260.                     {
  2261.                         if(!(MsgQualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)) && !Online && Phonebook[MsgCode] -> Header -> Number[0])
  2262.                         {
  2263.                             Selected = MsgCode;
  2264.  
  2265.                             LT_SetAttributes(Handle,GAD_NAMELIST,
  2266.                                 GTLV_Labels,    ~0,
  2267.                             TAG_DONE);
  2268.  
  2269.                             Count = 1;
  2270.  
  2271.                             for(i = 0 ; i < NumPhoneEntries ; i++)
  2272.                             {
  2273.                                 if(i != Selected)
  2274.                                 {
  2275.                                     SPrintf(Phonebook[i] -> Node -> LocalName,"      %s",Phonebook[i] -> Header -> Name);
  2276.  
  2277.                                     Phonebook[i] -> Count = -1;
  2278.                                 }
  2279.                                 else
  2280.                                 {
  2281.                                     SPrintf(Phonebook[i] -> Node -> LocalName,"  1 - %s",Phonebook[i] -> Header -> Name);
  2282.  
  2283.                                     Phonebook[i] -> Count = 0;
  2284.                                 }
  2285.                             }
  2286.  
  2287.                             DialTheList    = TRUE;
  2288.                             Done        = TRUE;
  2289.  
  2290.                             LT_PressButton(Handle,GAD_DIALLIST);
  2291.                         }
  2292.                     }
  2293.                 }
  2294.             }
  2295.             while(!Done);
  2296.  
  2297.             PopWindow();
  2298.         }
  2299.  
  2300.         LT_DeleteHandle(Handle);
  2301.     }
  2302.  
  2303.     if(PhonebookChanged)
  2304.         RebuildMenu = TRUE;
  2305.  
  2306.     FreeDialList(TRUE);
  2307.  
  2308.     if(PhoneList)
  2309.     {
  2310.         if(Count > 0)
  2311.         {
  2312.             TempNode = (struct PhoneNode *)PhoneList -> lh_Head;
  2313.  
  2314.             while(TempNode -> VanillaNode . ln_Succ)
  2315.             {
  2316.                 if(TempNode -> Entry -> Count != -1 && TempNode -> Entry -> Header -> Number[0])
  2317.                     SortToList(TempNode);
  2318.  
  2319.                 TempNode = (struct PhoneNode *)TempNode -> VanillaNode . ln_Succ;
  2320.             }
  2321.  
  2322.             if(!DialList)
  2323.                 DialTheList = FALSE;
  2324.         }
  2325.  
  2326.         DeletePhoneList(PhoneList);
  2327.     }
  2328.  
  2329.     return(DialTheList);
  2330. }
  2331.